package org.github.foxnic.web.generator.module.customer;


import com.foxnicweb.web.constants.db.CustomerTables;
import com.github.foxnic.generator.builder.business.option.ControllerOptions;
import com.github.foxnic.generator.builder.business.option.ServiceOptions;
import com.github.foxnic.generator.builder.model.PoClassFile;
import com.github.foxnic.generator.builder.model.VoClassFile;
import com.github.foxnic.generator.builder.view.option.*;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.generator.module.BaseCodeConfig;
import org.github.foxnic.web.generator.module.CustomerCodeStarter;


public class ContAcceptConfig extends BaseCodeConfig<CustomerTables.CUST_TEST> {

    public static void main(String[] args) {
        CustomerCodeStarter g=new CustomerCodeStarter();
        // 初始化本次需要生成代码的模块
        g.addConfig(new ContAcceptConfig());
        // 启动
        g.start();
    }
    public ContAcceptConfig() {
        super(PREFIX_CUSTOMER, CustomerTables.CUST_TEST.$TABLE,"cust_");
    }

    @Override
    public void configService(ServiceOptions service) {
    }

    @Override
    public void configModel(PoClassFile poType, VoClassFile voType) {

        poType.addSimpleProperty(Employee.class,"owner","owner","owner");
    }

    @Override
    public void configFields(ViewOptions view) {
        view.field(CustomerTables.CUST_TEST.ID)
                .basic().hidden();


        view.field(CustomerTables.CUST_TEST.USER_ID).table().fillBy("owner","name");
        view.field(CustomerTables.CUST_TEST.USER_ID).form()
                .button().chooseEmployee(true);



    }

    @Override
    public void configForm(ViewOptions view, FormOptions form, FormWindowOptions formWindow) {

        form.labelWidth(80);
        //分成分组布局
        view.formWindow().width("80%");
        form.addGroup(null,
                new Object[] {
                        CustomerTables.CUST_TEST.USER_ID,
                        CustomerTables.CUST_TEST.NOTES
                }

        );


    }

    @Override
    public void configController(ControllerOptions controller) {
        controller.restApiTagDir("客户模块");
    }

    @Override
    public void configSearch(ViewOptions view, SearchAreaOptions search) {
     //   search.disable();
        search.inputLayout(
                new Object[]{
                        CustomerTables.CUST_TEST.USER_ID,

                      }
        );
        search.labelWidth(1,70);
        search.labelWidth(2,70);
        search.labelWidth(3,70);
        search.labelWidth(4,70);
        search.rowsDisplay(1);
    }




    @Override
    public void configList(ViewOptions view, ListOptions list) {

    }

    @Override
    public void configOverrides() {
        //
        this.context.overrides()
                .setServiceIntfAnfImpl(WriteMode.COVER_EXISTS_FILE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.COVER_EXISTS_FILE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE) //列表HTML页
                .setExtendJsFile(WriteMode.COVER_EXISTS_FILE); //扩展页面

    }






}





